const express = require('express')
const homeRouter = require('./router/home')
const loginRouter = require('./router/login')
const aboutRouter = require('./router/about')

const app = express()

app.use(loginRouter)
app.use('/home', homeRouter)
app.use('/about', aboutRouter)

// 通常会在所有的路由之后配置处理 404 的内容
// 请求进来从上到下依次匹配
app.use((req, res, next) => {
  res.status(404).send('404 Not Found.')
})

app.listen(3000, () => {
  console.log(`Server running at http://localhost:3000/`)
})
